Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
Search form input - Search "as you type" with HTML/Javascript

I have following search form in an HTML page on website built with Django:

<form method="get">
<input class="form-control" type="text" name="q" id="id_q" placeholder="Search...">
</form>

I would like it to perform a search while typing (not having to press enter). I know we could use onchange or onkeyup, but I don't seem to be able to make it work.

The javascript at the bottom of the page is as follows:

<script type="text/javascript">
document.getElementById("id_q").value = "{{query}}"
</script>

Edit: I saw that my search works without the Javascript part above, but I still need to press on Enter. What would be a simple script to launch the search "as you type" without pressing Enter?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

once you onchange you can get your current values and send a API request or anything you want to do something like below-

window.addEventListener('load', () => {
  const input = document.getElementById("id_q");
  input.addEventListener('change', (e) => {
    let currentVal=e.target.value;
    // do anything with this value
  })
})

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda